<!--
 * @Author      : ZhouQiJun
 * @Date        : 2025-06-03 15:10:58
 * @LastEditors : ZhouQiJun
 * @LastEditTime: 2025-06-03 19:56:59
 * @Description : 首页
-->
<script setup lang="ts">
import { ref } from 'vue'
import TodoInput from '../components/TodoInput.vue'
const emits = defineEmits(['add'])

const todo = ref()

function onClick() {
  emitAdd()
}

function emitAdd() {
  emits('add', {
    title: todo.value,
    completed: false,
    id: Math.random().toString(36),
  })
  todo.value = ''
}
</script>

<template>
  <TodoInput v-model="todo" class="mr-2" />
  <button @click="onClick" class="button button--primary">添加</button>
</template>
